<script src="./dg.js"></script>
<script>
  const treeData = [
    {
      id: "p1",
      title: "广东",
      children: [
        {
          id: "p1-1",
          title: "广州",
        },
      ],
    },
    {
      id: "p2",
      title: "四川",
      children: [
        {
          id: "p2-1",
          title: "成都",
          children: [
            {
              id: "p2-1-1",
              title: "高新区",
            },
          ],
        },
        {
          id: "p2-2",
          title: "德阳",
        },
        {
          id: "p2-3",
          title: "绵阳",
        },
      ],
    },
  ];
  const value = [
    "60f930ee61a5ed00112c937b_93e52709c582451d8d7d3e8bc15bc674",
    "616aa750522fa600122c7dee_003614",
  ];

  let index = 1;
  let list = [];
  treeData.treeForEach((node) => {
    node.uuid = index++;
    console.log("node", node);
    list.push(node);
  });
  console.log("list", list);

  treeData.treeForEachTop((topNode) => {
      topNode.pId = 0;
      console.log("topNode", topNode);
    }, (chiNode, pNode) => {
      chiNode.pId = pNode.id;
      console.log("chiNode-pNode", chiNode, pNode);
    }
  );

  // const list = treeToList(treeData, 'children', 'parenId', 'uuid')
  // console.log("treeToList", list);
  // const res = []
  // getParId(list, ["p2-1"], res)
  // console.log("getParId", res);
</script>
